<template>
  <el-row>
    <el-container style="height:660px;">
      <el-col :span="11" style="border:1px solid rgba(121, 121, 121, 1)">
        <el-aside style="height:100%; padding:0;width:100%">
          <el-main style=" width:100%; padding:40px 40px;">
            <el-form label-width="120px">
              <el-row>
                <!-- 课程作业名称 -->
                <el-col :span="24">
                  <el-form-item label="课程作业名称" label-width="110px">
                    <el-input
                      v-model="homeworkDetails.homeworkTitle"
                      :readonly="true"
                      size="small"
                    />
                  </el-form-item>
                </el-col>
                <!-- 截止日期 -->
                <el-col :span="24" style="margin-top:50px">
                  <el-form-item label="截止日期" label-width="110px">
                    <el-input
                      v-model="homeworkDetails.deadline"
                      size="small"
                      :readonly="true"
                    />
                  </el-form-item>
                </el-col>
                <!-- 作业要求 -->
                <el-col :span="24" style="margin-top:50px">
                  <el-form-item label="作业要求" label-width="110px">
                    <textarea
                      size="small"
                      v-model="homeworkDetails.homeworkContent"
                      :readonly="true"
                      class="answerContent"
                      style="resize:none; outline:none"
                    />
                  </el-form-item>
                </el-col>
                <!-- 相关附件 -->
                <el-col :span="24" style="margin-top:50px">
                  <el-form-item label="相关附件" label-width="110px">
                    <a
                      v-for="(item,
                      index) in homeworkDetails.homeworkAttachmentList"
                      :key="index"
                      :href="item.link"
                      >{{ item.attachmentTitle }}</a
                    >
                  </el-form-item>
                </el-col>
                <!-- 提交状态 -->
                <el-col :span="24" style="margin-top:50px">
                  <el-form-item label="提交状态" label-width="110px">
                    <el-input
                      v-model="homeworkDetails.isCheck"
                      :readonly="true"
                      size="small"
                      class
                    />
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-main>
        </el-aside>
      </el-col>
      <el-col
        :span="12"
        style="border:1px solid rgba(121, 121, 121, 1);margin-left:12px;"
      >
        <el-main style=" width:100%; padding:40px 40px;">
          <el-form label-width="120px">
            <el-row>
              <!-- 回答内容 -->
              <el-col :span="24">
                <el-form-item label="回答内容" label-width="110px">
                  <textarea
                    size="small"
                    v-model="homeworkDetails.answerContent"
                    :readonly="true"
                    class="answerContent"
                    style="resize:none; outline:none"
                  />
                </el-form-item>
              </el-col>
              <!-- 回答附件 -->
              <el-col :span="24" style="margin-top:80px">
                <el-form-item label="回答附件" label-width="110px">
                  <a
                    v-for="(item,
                    index) in homeworkDetails.answerAttachmentList"
                    :key="index"
                    :href="item.link"
                    >{{ item.attachmentTitle }}</a
                  >
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <el-divider></el-divider>
          <el-form>
            <el-row>
              <!-- 批改分数 -->
              <el-col :span="24" style="margin-top:80px">
                <el-form-item label="批改分数" label-width="110px">
                  <el-input
                    v-model="homeworkDetails.score"
                    :readonly="true"
                    size="small"
                    class
                  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <a
            style="margin-top:50px;float:right;font-size:17px; color: rgb(12, 76, 142)"
            @click="back"
            >返回上一级</a
          >
        </el-main>
      </el-col>
    </el-container>
  </el-row>
</template>

<script>
export default {
  data() {
    return {
      // 这个参数从上一个页面跳转过来的时候获取
      requestParameter: {
        homeworkId: 9,
        studentId: "201830670001",
      },
      // 这个是请求返回的参数
      homeworkDetails: {
        // deadline: "2010.11.21.00.00",
        // homeworkContent: "填空题：第3题",
        // homeworkAttachmentList: [
        //   {
        //     attachmentId: 25,
        //     attachmentTitle: "测试文档",
        //     link:
        //       "https://mybucket-1304114494.cos.ap-guangzhou.myqcloud.com/%E5%BA%A7%E4%BD%8D%E8%A1%A8.xlsx",
        //   },
        // ],
        // isCheck: "未批改",
        // answerContent: "这里是回答内容",
        // answerAttachmentList: [
        //   {
        //     attachmentId: 25,
        //     attachmentTitle: "测试文档",
        //     link:
        //       "https://mybucket-1304114494.cos.ap-guangzhou.myqcloud.com/%E5%BA%A7%E4%BD%8D%E8%A1%A8.xlsx",
        //   },
        // ],
        // score: 98,
        // homeworkTitle: "第十章作业",
      },
    };
  },
  methods: {
    // 返回单项作业具体信息
    returnSingleHomework() {
      let options = {
        homeworkId: parseInt(this.$route.query.homeworkId),
        studentId: this.$store.state.id,
      };
      console.log(options);
      this.$http
        .post(this.$api.HomeworkqueryWorkConditionOfS, options)
        .then((resp) => {
          if (resp.success) {
            console.log("single homework");
            console.log(resp.data);
            this.homeworkDetails = resp.data;
          } else {
            this.$handleFailResp(this, resp);
          }
        });
    },

    back() {
      this.$router.push("/student/courseMangement/courseHomework");
    },
  },
  mounted() {
    this.returnSingleHomework();
  },
};
</script>

<style lang="less" scoped>
.el-divider--horizontal {
  margin: auto;
  width: 92%;
}

.el-input {
  width: 170px;
}

/deep/ .el-input.is-disabled .el-input__inner {
  color: black;
  border: 1px solid #8595a6;
  border-radius: 1px;
  //background-color: #edeff1;
  padding: 5px;
}

/deep/ .el-input__inner {
  color: black;
  border: 1px solid #8595a6;
  border-radius: 1px;
  //background-color: #fff;
  padding: 5px;
}

/deep/ .el-form-item__label {
  margin-right: 0px;
  text-align: left;
  color: #333333;
  font-size: 15px;
}

/deep/.el-input--small .el-input__inner {
  height: 25px;
}

.el-form-item {
  margin-bottom: 0px;
}

/deep/ .el-form-item__content {
  padding: 0;
}

.courseData {
  margin-top: 10px;
  width: 450px !important;
}

// 弹窗的样式
/deep/ .el-dialog__title {
  font-size: 23px;
  color: rgb(51, 55, 68);
}

.el-divider--horizontal {
  margin: auto;
  width: 95%;
  height: 2px;
  margin-top: 50px;
}

/deep/ .el-textarea__inner {
  border-radius: 0;
  height: 50px;
  padding: 10px 10px;
  font-size: 16px;
  width: 450px;
  color: #333333;
  border: 1px solid #333333;
}

.answerContent {
  border-radius: 0;
  height: 150px;
  padding: 10px 10px;
  font-size: 16px;
  width: 400px;
  color: #333333;
  border: 1px solid #333333;
  vertical-align: top;
  margin-top: 12px;
}
</style>
